﻿package core.ui.controls
{
    import flash.display.*;
    import flash.text.*;
    import flash.utils.*;

    public class BubbleBack extends Sprite
    {
        var uid:uint;
        var ref:Sprite;
        var message:TextField;

        public function BubbleBack(param1:Sprite)
        {
            this.ref = param1;
            this.message = new TextField();
            this.message.defaultTextFormat = new TextFormat("Verdana, Arial, Helvetica, San-serif", 13, 16777215);
            this.message.autoSize = TextFieldAutoSize.LEFT;
            this.message.multiline = false;
            this.message.selectable = false;
            this.message.height = 25;
            this.message.width = 260;
            addChild(this.message);
            this.visible = false;
            return;
        }// end function

        public function Show(beginFill:String) : void
        {
            this.message.text = U.RM(beginFill);
            var _loc_2:* = Math.round(this.message.width / 2) + 10;
            this.message.x = -Math.round(this.message.width / 2);
            this.message.y = -Math.round(this.message.height / 2) + 1;
            this.graphics.clear();
            this.graphics.beginFill(0, 0.7);
            this.graphics.drawRoundRect(-_loc_2, -10, _loc_2 * 2, 22, 15);
            this.graphics.endFill();
            this.alpha = 0;
            this.visible = true;
            var _loc_3:int = 0;
            this.scaleY = 0;
            this.scaleX = _loc_3;
            this.x = Math.round((this.ref.width - this.width) / 2);
            this.y = Math.round((this.ref.height - this.height) / 2);
            if (this.uid != 0)
            {
                clearTimeout(this.uid);
            }
            this.uid = setTimeout(this.FadeIn, 250);
            return;
        }// end function

        private function FadeIn() : void
        {
            this.alpha = this.alpha + 0.2;
            this.scaleX = this.scaleX + 0.2;
            this.scaleY = this.scaleY + 0.2;
            if (this.alpha < 1)
            {
                this.uid = setTimeout(this.FadeIn, 10);
            }
            else
            {
                this.scaleX = 1;
                this.scaleY = 1;
                this.uid = setTimeout(this.FadeOut, 750);
            }
            return;
        }// end function

        private function FadeOut() : void
        {
            this.alpha = this.alpha - 0.2;
            if (this.alpha > 0)
            {
                this.uid = setTimeout(this.FadeOut, 15);
            }
            else
            {
                this.visible = false;
                this.uid = 0;
            }
            return;
        }// end function

    }
}
